<template>
	<div style="padding:0px;">
		<el-form :model="dialogForm"  ref="dialogForm" :rules="rules" :label-width="formLabelWidth">
			<el-card class="box-card">
			  <div slot="header" class="clearfix">
			    <span style="line-height: 30px;">汽车及价格信息</span>
			  </div>
			  <div  class="text item">
			  	    <el-form-item label="订单号"  >
				      <el-input  v-model="dialogForm.orderNumber" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="经销商名称"  >
				      <el-input  v-model="dialogForm.dealerName" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="汽车数量" >
				      <el-input v-model="dialogForm.amount" auto-complete="off" disabled></el-input>
				    </el-form-item>
				    <el-form-item label="汽车车型" >
				      <el-input v-model="dialogForm.carBrandNameAndCarName" auto-complete="off" disabled></el-input>
				    </el-form-item>
				    <el-form-item label="汽车颜色" >
				      <el-input v-model="dialogForm.color" auto-complete="off" disabled></el-input>
				    </el-form-item>
				    
				    <el-form-item label="购车总价格"  class="currency">
				      <el-input :value="dialogForm.totalPrice | toFixed2" auto-complete="off" disabled></el-input>
				      <span class="convertCurrency" >{{dialogForm.totalPrice|convertCurrency}}</span>  
				    </el-form-item>
				    <el-form-item label="垫资金额"  class="currency">
				      <el-input :value="dialogForm.paymentAmount | toFixed2" auto-complete="off" disabled></el-input>
				      <span class="convertCurrency" >{{dialogForm.paymentAmount|convertCurrency}}</span>  
				    </el-form-item>
				    <el-form-item label="指导价/配置" >
				      <el-input  type="textarea" :rows=3 v-model="dialogForm.carConfig" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="上游购销合同" >
				      <qiniu :qiniuImage="qiniuImage"  :id="qiniuImage.id" :canDelete="false"></qiniu>
				    </el-form-item>
				    <el-form-item label="合同上游名称" >
				      <el-input  v-model="dialogForm.supplierName" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				  	
				    <el-form-item label="提车详细地址" >
				      <el-input  :value="dialogForm.supplierProvince+dialogForm.supplierCity+dialogForm.supplierAddress" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				  	<el-form-item label="提车联系人" >
				      <el-input  v-model="dialogForm.supplierPerson" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="联系人手机号" >
				      <el-input  v-model="dialogForm.supplierPhone" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				</div>
			</el-card>
			<el-card class="box-card"  style="margin-top:15px;">
			  <div slot="header" class="clearfix">
			    <span style="line-height: 30px;">确认信息</span>
			  </div>
			  <div  class="text item" >
                <el-form-item label="审核信息"  class="is-required">
  			        <el-radio-group v-model="dialogForm.priceStatus"  :disabled="!dialogSendData.isAdd" >
  				      <el-radio :label="3" > 通过 </el-radio>
  				      <el-radio :label="1" > 不通过 </el-radio>
  				    </el-radio-group>
  			    </el-form-item>
			    <el-form-item label="审核备注"  prop="priceRemark" ><!-- :rules="this.dialogForm.priceStatus!=3?rules.priceRemark:[{ required: false, message: '请填写审核备注', trigger: 'blur' }]" -->
			      <el-input type="textarea" :rows=3 v-model="dialogForm.priceRemark" auto-complete="off" :maxlength=100
			      :disabled="!dialogSendData.isAdd" ></el-input>
			    </el-form-item>
	          </div>
			</el-card>
		
		</el-form>
		<div style="text-align:right;margin-top:15px;">
			 <el-button @click="returnBack">返 回</el-button>
			 <el-button v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
		</div>
	</div>
</template>
<script>
    import agentHttp from '@/utils/agentHttp.js';
    import {require,length100} from '@/utils/rules.js';
     import qiniu from '@/views/qiniu/upload';
	export default{
		created(){
   			if(this.dialogSendData.id!==""){
	      		this.selectData();//修改      	    
	      	}
        },
		props:['dialogSendData','tableData'],
		components:{qiniu},
		data(){
			return{
				formLabelWidth:'170px',
				//弹窗或者查看页面信息
		        dialogForm:{
		        	imagUrl:[],
		        	qcsl:"",
		        	carOrder:1,
		        	logisticsCompany:"",
		        	resource:""
		        },
		        
		        logisticsCompanyOptions: [{
		          value: '1',
		          label: '价格审核'
		        }],
		        //验证规则：
			    rules: {
			        priceRemark: [
			          { required: true, message: '请填写审核备注', trigger: 'blur' }
			        ]
			    },
			    qiniuImage:{
			        	id:"qiniuImage", //图片预览的id   
			        	image_uri:[],    //图片上传的列表  只含有url地址
			      },
			        
			}
		},methods:{
			returnBack(){
				this.dialogSendData.dialogFormVisible=false;
			},
			submitConfirmForm(formName){				
                this.$refs[formName].validate((valid) => {
		          if (valid) {
		          	if(this.dialogSendData.id===""){
		          		//添加
		          	}else{		          		
		          		this.editData();//修改
		          	}
		          	setTimeout(()=>{
		          		this.dialogSendData.dialogFormVisible=false;
		          	},500)
		          	
		          } else {
		            this.$nextTick(()=>{
			          	this.$message.warning(document.getElementsByClassName('el-form-item__error')[0].innerText);
			            return false;
		            })
		          }
		        });
			},
			editData(){
		        agentHttp.putJson('adminApi/admin/car_order_price/price_audit_order',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshSeachData', null);
		            	this.$message.success(data.data||"修改成功");
		            } 
		        }) 
		    },
		    selectData(){
		        agentHttp.get('adminApi/admin/car_order_price/select_order/'+this.dialogSendData.id).then((data)=>{	
		            if(data.success){
		            	this.dialogForm=data.data;
		            	this.dialogForm.contracts?this.qiniuImage.image_uri= this.dialogForm.contracts.split(',').notempty():"";
		            	this.dialogForm.carBrandNameAndCarName=data.data.carBrand+data.data.carName;
		            	if (this.dialogSendData.isAdd&&data.data.priceStatus==2) {
                         this.dialogForm.priceStatus=3;
		            	}

		            } 
		        }) 
		    }
		    
		}
	};
	
</script>